package com.hyts.apidoc.swagger;

import com.hyts.apidoc.swagger.html.HtmlDocTransfer;
import com.hyts.scanner.facade.ScannerBuilder;
import io.swagger.annotations.SwaggerDefinition;
import lombok.AllArgsConstructor;

import java.util.List;

/**
 * project-name:coffice-toolbox
 * package-name:com.hyts.apidoc.swagger
 * author:Libo/Alex
 * create-date:2019-05-17 10:52
 * email:liboware@gmail.com
 * description:此类主要用于: swagger api doc 文件输出文档功能开发
 */
@AllArgsConstructor
public class SwaggerApiDoc {


    HtmlDocTransfer htmlDocTransfer;


    public SwaggerApiDoc() {
        this.htmlDocTransfer = new HtmlDocTransfer();
    }

    /**
     * 提交初始化相关的package的swagger注解功能
     * @param packageName
     * @return
     */
    public List<Class<?>> init(String... packageName){
        List<Class<?>> scanClassList = ScannerBuilder.create().includePackage(packageName)
                .annotation(SwaggerDefinition.class).scanToClass(true);
        return scanClassList;
    }

    /**
     * 提交初始化相关的package的swagger注解功能
     * @return
     */
    public List<Class<?>> init(){
        List<Class<?>> scanClassList = ScannerBuilder.create().includePackage(
                SwaggerApiDoc.class.getPackage().getName())
                .annotation(SwaggerDefinition.class).scanToClass(true);
        return scanClassList;
    }

    /**
     * 创建html文件
     * @param swaggerYml
     * @param outputFilePath
     */
    public void createHtml(String swaggerYml,String outputFilePath){
        htmlDocTransfer.createHtml(swaggerYml,outputFilePath);
    }
}
